<?php


namespace api\web\controller;


use api\web\model\NewsModel;
use cmf\controller\RestBaseController;
use think\facade\Db;


class NewsController extends RestBaseController
{
    public function index()
    {
        $page = input('page/d','2');
        $page_size = input('page_size/d','1');
        $res = NoticeModel::order('list_order','desc')
            ->withoutField('delete_time,content,look_num')
            ->page($page,$page_size)
            ->select();
        $this->success('学院新闻列表',$res);
    }

    public function content()
    {
        $id = input('id/d');
        if(empty($id))
        {
            $this->error('id不能为空');
        }
        $res = NewsModel::find($id);
        $res['content'] = cmf_replace_content_file_url(htmlspecialchars_decode($res['content']));
        $this->success('查看文章详情',$res);
    }
}